<?php
class ProductModel
{

    /*
        获取药品信息
        params
            product_id
            field 查询字段
    */
    public function getProductInfoById($product_id = '', $field = "*")
    {
        $Dao = M("sysyaodian.kfsys_products");

        $where = sprintf("id = %d", $product_id);

        $productInfo = $Dao
            ->field($field)
            ->where($where)
            ->find();

        return $productInfo;
    }

    /*
        通过条形码查询商品id
        params
            upc 商品条形码
    */
    public function getProdcutIdByUPC($upc = '')
    {
        $Dao = M("sysyaodian.kfsys_products");

        $where = sprintf("BarCode = '%s'", $upc);

        $productInfo = $Dao
            ->field("ID")
            ->where($where)
            ->find();

        return $productInfo['ID'];
    }
}
?>